home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-03-04 | 1.7 KB | 79 lines | [TEXT/ToyS] |
- on open fsObjs
- repeat with fsObj in fsObjs
- set drawWin to ¬
- display drawing titled ¬
- "Previewer" with dimensions {256, 288}
-
- ShowOne(drawWin, fsObj)
-
- display drawing drawWin with disposal
- end repeat
- end open
-
-
- on ShowOne(drawWin, fsObj)
- -- Get file name
- set fname to catalog name of (basic info for fsObj)
-
- try
- -- Get preview if available
- set fsPreview to the resource fsObj ¬
- of type "PICT" with index 1
- on error
- -- Else get icon
- set fsPreview to (the icon for fsObj) as picture
- end try
-
- -- Get the picture's box
- set pictBox to picture bounds of ¬
- (the picture info for fsPreview)
-
- -- Center it within 0,0,256,256
- set myBox to PlaceInCenter(pictBox, {0, 0, 256, 256})
-
- -- Draw it double size (scale {2,2})
- draw a picture into drawWin ¬
- using data fsPreview ¬
- inside of myBox ¬
- with a clear slate
-
- -- Invert bottom
- draw a box into drawWin ¬
- inside of {0, 256, 256, 288} ¬
- filling it with the pen
-
- -- Draw the name
- draw a string into drawWin ¬
- using data fname ¬
- offset by {128, 280} ¬
- using state {text size:18, text font:1, fg color:"FFFFFF"}
-
- pause for 2 with seconds timing
- end ShowOne
-
-
- on PlaceInCenter(src, dst)
- set sW to (item 3 of src) - (item 1 of src)
- set sH to (item 4 of src) - (item 2 of src)
- set dW to (item 3 of dst) - (item 1 of dst)
- set dH to (item 4 of dst) - (item 2 of dst)
-
- set r to dW / sW
- set rH to dH / sH -- ratios
-
- if (rH < r) then set r to rH
-
- -- Round to a .25 ratio if > 1
- if (r > 1) then ¬
- set r to 0.25 * (round (r * 4))
-
- -- Scale the src
- set sW to round (sW * r)
- set sH to round (sH * r)
- set mW to round ((dW - sW) / 2)
- set mH to round ((dH - sH) / 2)
-
- -- Center it
- return {mW, mH, mW + sW, mH + sH}
- end PlaceInCenter
-